home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / rpn141.arc / RPN.DOC next >
Text File  |  1985-09-11  |  41KB  |  977 lines

  1.  
  2.  
  3.            RPN CALCULATOR PROGRAM - VERSION 1.41
  4.               Copyright (c) 1984,85  Tom Ginn
  5.  
  6. NAME:
  7.  
  8.     RPN
  9.  
  10. COMMAND STRING:
  11.  
  12.     RPN [RAMFSBn=x]
  13.  
  14. SUMMARY:
  15.  
  16. RPN is a calculator program written in C (mostly) and compiled with the
  17. DeSmet C development package.  It runs on the IBM PC under PC-DOS and
  18. hopefully on most IBM PC compatible machines using PC-DOS or MS-DOS. 
  19. Either color or monochrome display may be used.  RPN uses up about 54K
  20. of memory so you will need total system memory of at least 96K to run
  21. it, and more if you plan to install it in the background.  The features
  22. of the program include:
  23.  
  24.      1. Reverse Polish (RPN) or algebraic operation
  25.      2. Operation in number bases from 2 to 16
  26.      3. Easy number base conversion
  27.      4. Fixed point or Scientific (base 10 only) notation
  28.      5. Financial calculations
  29.      6. Summation, mean & standard deviation
  30.      7. User defined macro keypoke sequences
  31.      8. 8087 math chip support
  32.      9. Trig, Log, Exponential operations
  33.     10. Calendar display
  34.     11. Ability to remain memory resident in the background
  35.     12. Ability to use BIOS routines or go directly to
  36.         screen memory for faster output.
  37.  
  38. Please note: the memory resident and direct screen output features
  39. depend on IBM-PC screen memory and video mode compatibility.  While
  40. vanilla RPN has worked on every PC compatible I've tried it on
  41. including PC jr, and I have not yet had any problems running the memory
  42. resident and direct screen features on the machines I've been able
  43. to try, there is still room for these features to fail on some
  44. machines.
  45.  
  46. PROGRAM DISTRIBUTION:
  47.  
  48. RPN is distributed on a single sided 8 sector MS-DOS/PC-DOS 
  49. diskette containing the following files:  
  50.  
  51.     1) RPN.EXE - The calculator program with software floating point 
  52.     for systems without the 8087 math co-processor.
  53.     2) RPN7.EXE - The calculator program with 8087 floating point 
  54.     support for systems with the 8087 math co-processor.
  55.     3) RPN.DOC - This documentation file.
  56.     4) RPN.R1, RPN.A1 and RPN.R2 - Sample macro files in the format 
  57.     saved by the macro save operation.
  58.  
  59. We are all familiar with the current marketing strategy for software
  60. products: use copy protection, accept the fact that there will be
  61. unauthorized copies made, and charge an arm and a leg to try to
  62. compensate for it.  Well, with RPN there is no copy protection, all
  63. copies are authorized, and, by the way, you can keep your leg and most
  64. of your arm.
  65.  
  66. You are welcome to make copies of RPN for your personal use and
  67. encouraged to pass it along to your friends.  If you find RPN useful
  68. and decide to keep a copy, I will hope to receive a small honorarium 
  69. from you.  I suggest $10.00 as an appropriate amount but leave the
  70. final decision to you.  Procrastination is my worst enemy in this
  71. endeavor, so please don't put it off. Send to:
  72.  
  73.     Tom Ginn
  74.     P.O. Box 24842
  75.     San Jose, CA  95154-4842
  76.  
  77. If you prefer, you may order a program diskette of the current revision
  78. level from me for $15.00. Orders from California residents should include
  79. sales tax.  
  80.  
  81. This method of software distribution can succeed only with your
  82. co-operation. If you would like to see greater use of this medium to
  83. distribute useful software at minimal cost, please support this
  84. program and others like it. 
  85.  
  86. Please Note....
  87.     **  When you copy RPN be sure to pass along all the files.
  88.     **  Do not circulate modified copies of RPN.
  89.     **  Do not remove this message from the RPN files.
  90.  
  91. While I have made every effort to locate and remove insect life from
  92. this program, there is an unwritten law that says any non-trivial
  93. software package will have bugs, and I don't expect this program to be
  94. exempt from the laws of nature.  Therefore I must distribute RPN "as
  95. is" to be employed at the user's risk, and can assume no liability for
  96. any losses or damages of any kind resulting from use or misuse of the
  97. program.  No express or implied warranties regarding merchantability or
  98. fitness of use shall apply.
  99.  
  100. Comments, suggestions, and/or reports of encounters with any remaining
  101. insect life may be directed to the author at the above address.  If
  102. your correspondence requires a reply, please enclose a self addressed
  103. stamped envelope to help speed things up.  Thank you for your interest
  104. in my calculator program.  I hope you will find it as useful as I do.
  105.  
  106. DESCRIPTION:
  107.  
  108. RPN is executed by typing its name and optional parameters specifying
  109. the desired mode of operation in response to the prompt from the
  110. MS-DOS command processor:
  111.  
  112.     RPN [RAMFSBn=x]        (RPN7 for the 8087 load)
  113.  
  114.     Where:
  115.  
  116.        R - RPN mode. The program will run in RPN mode and
  117.            will attempt to load a macro file RPN.R0 (this
  118.            is the default mode).
  119.  
  120.        A - Algebraic mode. The program will run in algebraic
  121.            mode and will attempt to load a macro file RPN.A0.
  122.  
  123.        M - Override color attributes with white on black.
  124.  
  125.        F - Fast mode. This parameter causes the screen output
  126.            to bypass the BIOS and go direct to screen memory.
  127.            You'll be amazed at the difference.
  128.  
  129.        S - Stay resident in memory. RPN will install itself
  130.            in memory and be ready to run when it sees a
  131.            special activation code from the keyboard.
  132.            When running resident, fast mode is implied.
  133.  
  134.        B - Blink scroll handling.  You may also be amazed by the
  135.             amount of noise fast mode makes on your screen if you
  136.             have the IBM color card or a similar one that doesn't
  137.             like to have the cpu access screen memory during
  138.             display.  If so, use this option when you are using F
  139.             or S to tell RPN to synchronize output to the screen
  140.             with the horizontal retrace so it doesn't show.  It
  141.             slows down fast mode a bit but it's worth it.
  142.  
  143.        =x - The default activation code is CTRL-ALT-C but this
  144.            parameter will change it to the letter you specify
  145.            immediately following the = sign.
  146.  
  147.        n - Macro file number from 0-9. Allows you to specify
  148.            the macro file number to be loaded. See section
  149.            on saving macros for more on macro files.
  150.  
  151. Examples:
  152.  
  153.     RPN        vanilla RPN
  154.     RPN7        8087 load of RPN
  155.     RPN A        algebraic mode
  156.     RPN AF        algebraic and fast modes
  157.     RPN S        memory resident
  158.     RPN SB        memory resident with blink scroll handling
  159.     RPN S=Z        memory resident with CTRL-ALT-Z activation
  160.     RPN F5        fast mode, load macro file RPN.R5
  161.  
  162. Please note: If the 8087 load of RPN is executed on a system without
  163. the 8087 co-processor present it will hang the computer and you will
  164. have to re-boot (CTRL-ALT-DEL will do it). If the non-8087 load is
  165. executed on a machine with an 8087 installed there are no ill effects
  166. but you will not take advantage of the 8087 speed.
  167.  
  168. If no parameters are specified the program will determine the operating
  169. mode by the macro files that are present.  It looks first for RPN.R0
  170. and if it is present then RPN mode is used and RPN.R0 is loaded.  If it
  171. doesn't find RPN.R0 then it looks for RPN.A0 and if it is found then
  172. algebraic mode is used and RPN.A0 is loaded.  If neither macro file is
  173. found the program will default to RPN mode with predefined color
  174. attributes. You may specify a macro file number to determine the
  175. macro file that is used instead of the default 0.
  176.  
  177. The program execution is terminated by poking the Escape key (ESC).
  178. If RPN is running as a normal program it will return control to the
  179. operating system. If RPN is running as a background program entered
  180. by the CTRL-ALT-whatever activation code, it will return to the
  181. interrupted program.
  182.  
  183. In the default RPN (Reverse Polish Notation) mode, the program behaves
  184. in many respects like a Hewlett-Packard RPN calculator with a 4
  185. register stack ( x, y, z, & t registers ), 10 memory registers, and a
  186. last x register.  All 4 registers of the stack are displayed on the
  187. screen and the calculations operate on the x register only or on the x
  188. and y registers, leaving the result in the x register or x and y
  189. registers.
  190.  
  191. The following keys are used to execute the calculator's operations.
  192. A short description will be given here for each key used, and more
  193. detailed information on some operations will appear later in this
  194. manual.  Poking a key for which no operation is defined just rings a
  195. bell at you.
  196.  
  197. 0-9    Number entry.
  198.  
  199. A-F    Hex number entry.
  200.  
  201. .    Decimal point entry.
  202.  
  203. +    y+x  Since some keyboards don't have a plus you can get to
  204.     without the shift key, TAB is equivalent to +.
  205.  
  206. -    y-x
  207.  
  208. /    y/x
  209.  
  210. *    y*x  Since some keyboards don't have an * you can get to
  211.     without the shift key, COMMA is equivalent to *.
  212.  
  213. %    y%x  Remainder of y/x or y mod x.  This operation is limited
  214.     to integer operands less than 2,147,483,648 (2^31).
  215.  
  216. ^    Pow(y,x)  y raised to the x power.
  217.  
  218. &    y AND x  Logical bitwise AND of y and x register values.
  219.     This operation is limited to integer operands less than 
  220.     2,147,483,648 (2^31).
  221.  
  222. |    y OR x  Logical bitwise Inclusive OR of y and x register values.
  223.     This operation is limited to integer operands less than 
  224.     2,147,483,648 (2^31).
  225.  
  226. $    y XOR x  Logical bitwise Exclusive OR of y and x register values.
  227.     This operation is limited to integer operands less than 
  228.     2,147,483,648 (2^31).
  229.  
  230. ~    Negate x
  231.  
  232. !    x factorial
  233.  
  234. \    Alternate operation prefix.  When this key is poked, "shift" is
  235.     written on the message line to signify alternate interpretation
  236.     of the next key poked.
  237.  
  238. #    Macro function flag. This character, inserted at the beginning
  239.     of a macro, indicates that you want the macro treated as a
  240.     function which returns a value to the x register.
  241.  
  242. []    Macro comment brackets.  Characters between brackets in a macro
  243.     string will be ignored.  This allows short comments to be
  244.     included in saved macro strings.
  245.  
  246. =    Enter key (RPN mode) or Equals key (Algebraic mode).  Note
  247.     several alternates are interpreted as ENTER for keypoking ease.
  248.  
  249. CR    Enter key (RPN mode) or Equals key (Algebraic mode). The CR
  250.     (carriage return) key generates the same code as Control-M 
  251.     and on various keyboards may be labeled "RETURN", "CR", 
  252.     or "ENTER".
  253.  
  254. LF    Enter key (RPN mode) or Equals key (Algebraic mode). The LF
  255.     (line feed) key generates the same code as Control-J and on
  256.     various keyboards may be labeled "LINE FEED" or "NEW LINE"
  257.     or may not be present at all.
  258.  
  259. space    Enter key (RPN mode) or Equals key (Algebraic mode).
  260.  
  261. F1    Function keys F1-F10 execute assigned macros.
  262.  
  263. \F1    Function keys F1-F10 copy the macro function key definition to 
  264.     the scratch string for macro editing. If the macro string is
  265.     defined it is displayed on the message line.
  266.  
  267. a    Screen setup for normal calculator mode.  Can also be used to
  268.     rewrite the calculator screen in case the display gets trashed. 
  269.     Displays the status line, register stack, message line, and
  270.     calculator help text.
  271.  
  272. \a    Screen setup for financial mode.  Enables the financial
  273.     operation keys.  Displays status line, register stack, message
  274.     line, financial registers, and financial help text. The normal
  275.     calculator functions are still available, too.
  276.  
  277. b    Set number base.  The calculator is capable of doing most of
  278.     its numeric input and output in any number base from 2 to 16.
  279.  
  280. \b    Memory display mode.  An alternate display screen in normal
  281.     calculator mode shows the 10 memory registers in place of the
  282.     help text in the lower half of the screen.
  283.  
  284. c    Cos(x)  Cosine of x.
  285.  
  286. \c    Arccos(x) - Angle whose cosine is x.
  287.  
  288. d    Set display format.  The display format may be set to either
  289.     fixed point or scientific notation and the number of places
  290.     right of the decimal point may be varied from 0 to 9.
  291.  
  292. \d    Set degrees mode for trig functions and rectangular/polar conversions.
  293.  
  294. \D    Debug toggle.  This turns on (or off) some debugging messages
  295.     that were handy enough to keep available.  One is output of the
  296.     x and y registers so their internal 64 bit storage format can
  297.     be seen as 4 hex words.  Another is intermediate values of the
  298.     iterative process used to calculate interest rate in the
  299.     financial mode.
  300.  
  301. e    Enter exponent.  For entry of numbers in scientific notation
  302.     when number base is decimal.  '-' or '~' changes sign of
  303.     exponent.  Any key not '0'-'9', '-' or '~' terminates entry and
  304.     is interpreted as the next operation key.
  305.  
  306. \e    Screen setup for summation mode.  Displays status line, register 
  307.     stack, message line, summation registers, and summation help text.
  308.     Provides for summation of a number of values entered into the 
  309.     x register and computation and display of the mean and standard 
  310.     deviation.
  311.  
  312. f    Frac(x) Keep fractional part of x.  The integer part of the
  313.     floating point number in the x register is discarded.
  314.  
  315. \f    Calendar display mode. This draws the calendar screen and
  316.     switches over to the calendar commands, which are described
  317.     later. In calendar mode the normal calculator commands
  318.     are disabled.
  319.  
  320. i    Int(x) Keep integer part of x.  The fractional part of the
  321.     floating point number in the x register is discarded.
  322.  
  323. k    Rectangular to polar.  The x and y registers are assumed to
  324.     contain rectangular x and y coordinates, respectively, and are
  325.     converted to polar coordinates (r, theta).  The resulting r is
  326.     left in the x register and theta is left in the y register.
  327.     If you use this while in algebraic mode, you will have to use
  328.     the "x" key (exchange) to load the y register.
  329.  
  330. \k    Polar to rectangular.  This is the inverse of the rectangular
  331.     to polar conversion. Again, in algebraic mode the "x" key is
  332.     used to load the y register.
  333.  
  334. l    Log10(x)  Log of x to base 10.
  335.  
  336. \l    Pow(10,x)  Raise 10 to the x power (antilog of x).
  337.  
  338. L    Last x.  Whenever an operation is executed which calculates a
  339.     result and leaves it in the x register, the old value contained
  340.     in the x register is saved in the "last x" register.  The last
  341.     x key retrieves the saved value and pushes it on the stack.
  342.  
  343. m    Execute macro.
  344.  
  345. \m    Define macro.
  346.  
  347. M    Edit macro.
  348.  
  349. \M    Save macros in a disk file.
  350.  
  351. n    Ln(x)  Natural log of x.
  352.  
  353. \n    Exp(x)  Raise e to the x power (exponential of x).
  354.  
  355. o    1/x  Reciprocal of x.
  356.  
  357. p    Pi  Push Pi on the stack.
  358.  
  359. q    Sqrt(x)  Square root of x.
  360.  
  361. \q    x * x  Square of x.
  362.  
  363. r    Recall from memory register and push on the stack. This operation
  364.     is also used to move financial and summation register values to
  365.     the operational stack so they can be used in normal calculations.
  366.  
  367. R    Recall from memory register. Same as "r" for convenience.
  368.  
  369. \r    Set radians mode for trig functions and rectangular/polar conversions.
  370.  
  371. s    Sin(x)  Sine of x.
  372.  
  373. \s    Arcsin(x)  Angle whose sine is x.
  374.  
  375. t    Tan(x)  Tangent of x.
  376.  
  377. \t    Arctan(x)  Angle whose tangent is x.
  378.  
  379. v    Rotate down.
  380.  
  381. V    Rotate down. Same as "v" for convenience.
  382.  
  383. \v    Rotate up.
  384.  
  385. \V    Rotate up. Same as "\v" for convenience.
  386.  
  387. w    Write x in memory register.  Optionally add x to memory,
  388.     subtract x from memory, multiply x by memory, or divide x into
  389.     memory, storing the result into memory.
  390.  
  391. W    Write x in memory register. Same as "w" for convenience.
  392.  
  393. x    Exch(y,x)  Exchange x and y register values.
  394.  
  395. X    Exch(y,x)  Same as "x" for convenience.
  396.  
  397. \x    Clear the summation registers.
  398.  
  399. \X    Clear the summation registers. Same as "\x" for convenience.
  400.  
  401. y    Clear financial registers.
  402.  
  403. Y    Clear financial registers. Same as "y" for convenience.
  404.  
  405. \y    Clear memory registers.
  406.  
  407. \Y    Clear memory registers. Same as "\y" for convenience.
  408.  
  409. z    Clear x register.
  410.  
  411. Z    Clear x register. Same as "z" for convenience.
  412.  
  413. \z    Clear stack.
  414.  
  415. \Z    Clear stack. Same as "\z" for convenience.
  416.  
  417. The following operations make up the finiancial section of the
  418. calculator.  The Enter/Compute and \p keys are disabled in normal
  419. calculator mode and are enabled when you change to the financial mode.
  420.  
  421. \a    Redraw financial screen.
  422.  
  423. I    Enter/compute Interest Rate.
  424.  
  425. N    Enter/compute Number of Periods.
  426.  
  427. P    Enter/compute Payment.
  428.  
  429. S    Enter/compute Start (Present) value (PV).
  430.  
  431. T    Enter/compute Terminal (Future) value (FV).
  432.  
  433. \p    Set the financial period to use. This will be day, week,
  434.     month, quarter, or year. If it makes sense to do so, the
  435.     number of periods will be converted to the new period
  436.     and the new periodic payment will be calculated.
  437.  
  438. r    Recall. "r" followed by the register letter is used to move a
  439.     value from a financial register to the operational stack so it
  440.     can be used in normal calculations.
  441.  
  442. y    Clear financial registers.
  443.  
  444. The following operations make up the summation section of the
  445. calculator.
  446.  
  447. \e    Redraw screen.
  448.  
  449. u    Summation (+). The value from the x register is summed in the
  450.     summation registers and the mean and standard deviation values
  451.     are computed and displayed.
  452.  
  453. \u    Summation Correction (-). If an erroneous value is summed with
  454.     the "u" operation it can be removed from the summation by entering
  455.     the value to be removed in the x register and using "\u".
  456.  
  457. \x    Clear the summation registers.
  458.  
  459. r    Recall. "r" followed by the register letter is used to move a
  460.     value from a summation register to the operational stack so it
  461.     can be used in normal calculations.
  462.  
  463. The following commands are available in calendar display mode.  When
  464. the calendar display mode is active, the rest of the calculator
  465. functions are disabled.
  466.  
  467. 0-9    Enter a year. Each time a digit is typed the existing year is
  468.     multiplied by 10, the new digit is entered into the ones position,
  469.     and a calendar is generated. The calendar has a range from year
  470.     0001 to 10000.
  471.  
  472. F1/F2    Go back/forward 1 month. For convenience the left arrow and
  473.     right arrow cursor motion keys are also plugged into these
  474.     functions.
  475.  
  476. F3/F4    Go back/forward 1 year. For convenience the down arrow and up
  477.     arrow cursor motion keys are also plugged into these functions.
  478.  
  479. F5/F6    Go back/forward 1 decade (10 years).
  480.  
  481. F7/F8    Go back/forward 1 century (100 years).
  482.  
  483. Home    Displays the calendar for today's date. Today is determined by
  484.     reading the system time so you should set your clock for this
  485.     to come out right. The "t" key is also plugged into this action.
  486.  
  487. End    Leave calendar mode. The program will re-enter the calculator
  488.     mode that was active when calendar mode was started up. The "x"
  489.     key is also plugged into this action.
  490.  
  491. RPN vs. ALGEBRAIC
  492.  
  493. You will see the difference between RPN mode and algebraic mode in
  494. operations which act on two operands(+ - * / % ^ & | $).  Reverse
  495. Polish Notation requires that you first put the numbers to be operated
  496. on into the stack and then poke the appropriate key to inform the
  497. program what you want it to do.  The "Enter" key is used to separate
  498. the entry of the two numbers.  To multiply 2 times 3 the keypoke
  499. sequence is:
  500.  
  501.     2 Enter 3 *
  502.  
  503. As you poke the keys, you will see the stack be updated on the screen
  504. with each keypoke.  These are the stack displays you will see during
  505. the example calculation:
  506.  
  507.             2    Enter    3    *
  508.     t:    0.00    0.00    0.00    0.00    0.00
  509.     z:    0.00    0.00    0.00    0.00    0.00
  510.     y:    0.00    0.00    2.00    2.00    0.00
  511.     x:    0.00    2.00    2.00    3.00    6.00
  512.  
  513. A slightly more complicated example (2 * 3 + 4 * 5) adds another
  514. product to the result of the first product and shows the use of RPN and
  515. the register stack to preserve an intermediate result for later use. 
  516. We start off with the result of the first product remaining in the x
  517. register, use the same procedure to multiply 4 times 5, and then poke
  518. the "+" key to add the two product results:
  519.  
  520.             4    Enter    5    *    +
  521.     t:    0.00    0.00    0.00    0.00    0.00    0.00
  522.     z:    0.00    0.00    6.00    6.00    0.00    0.00
  523.     y:    0.00    6.00    4.00    4.00    6.00    0.00
  524.     x:    6.00    4.00    4.00    5.00    20.00    26.00
  525.  
  526. If you are uncomfortable with the RPN mode, the calculator may be run
  527. in its algebraic mode.  In algebraic mode only the x and y registers
  528. are displayed and operation is modified so the keypoke sequence to
  529. multiply 2 times 3 becomes the familiar:
  530.  
  531.     2 * 3 =
  532.  
  533. In algebraic mode the ability to preserve an intermediate result on the
  534. stack is gone but the memory registers can be easily used instead. To
  535. use the rectangular/polar conversion in algebraic mode it is necessary
  536. to use the exchange function ("x") to get the y register loaded with
  537. its parameter.
  538.  
  539. MEMORY RESIDENT MODE and FAST MODE
  540.  
  541. RPN can be run either as a normal program or as a resident background
  542. utility.  You install it in the background by executing it with the "s"
  543. parameter on the command line.  Instead of the normal calculator screen
  544. you will see something like this:
  545.  
  546.     A> RPN S
  547.  
  548.     RPN/Algebraic Calculator - Version 1.41
  549.     Copyright (c) 1984,85  Tom Ginn
  550.  
  551.     Installed in background. Activate with CTRL-ALT-C
  552.     when the running program is waiting for key input.
  553.  
  554.     A>
  555.  
  556. From this point on you may get into RPN by typing the activation code
  557. whenever (almost) the running program is expecting keyboard input.  I
  558. say "almost" because the command.com command line input can only be
  559. interrupted if it is a fresh prompt and no other characters have been
  560. typed before the activation code.  RPN will silently refuse to activate
  561. itself if command.com is active and you have typed any characters in
  562. response to the command prompt. In this case all you need to do is type
  563. CTRL-C to clear the entered characters and get a fresh prompt.
  564.  
  565. You may interrupt any standard IBM-PC video mode and return to it when
  566. you exit RPN. Some cautions should be observed, however:
  567.  
  568.     1. If you have a video card with non-standard video modes,
  569.         DON'T interrupt a non-standard mode. RPN doesn't
  570.         know how to restore anything but standard modes.
  571.  
  572.     2. If you have a mouse running and a mouse cursor on the
  573.         screen you interrupt, don't move the mouse while
  574.         RPN is active. The mouse interrupt handler is still
  575.         running and trying to update screen memory and you
  576.         may see it on the RPN screen. Your interrupted screen
  577.         may not be quite as you left it either.
  578.  
  579.     3. If you have two or more background routines installed, it's
  580.         best not to interrupt one to enter another. RPN and some
  581.         other background programs change video mode by programming
  582.         the video card directly rather than call the BIOS to change
  583.         the mode. I found this to be necessary to keep a mouse
  584.         cursor from getting lost. The video mode may not be properly
  585.         restored when returning to another background program.
  586.  
  587.     4. If you use RPN in the background along with Borland's
  588.         Sidekick, install RPN before Sidekick.  You won't have any
  589.         trouble getting to Sidekick with the CTRL-ALT combination. 
  590.         To get RPN, hold CTRL-ALT down until Sidekick's menu window
  591.         goes away before pressing the "C" to get RPN.
  592.  
  593. If you install RPN in the background of a PC jr, you will find that
  594. it only allows the activation sequence to proceed if the computer is
  595. already in the video mode required (mode 2 or 3). You can't interrupt
  596. any other mode because RPN does not handle the mode changes on the jr.
  597. I think most jr's will not have enough memory available to install
  598. background utilities anyway.
  599.  
  600. If you find it necessary or desirable to have RPN use a different
  601. activation code than the default CTRL-ALT-C, you can use the =x
  602. parameter to specify any letter of the alphabet to replace the default
  603. C.  For example, to install RPN with an activation code of CTRL-ALT-R,
  604. install RPN in memory with the command:
  605.  
  606.     RPN S=R
  607.  
  608. The "fast" mode is required by and automatically set by the resident
  609. mode. However, "fast" mode is available by itself when the program
  610. is executed normally by using the "F" parameter on the command line.
  611. Try it both ways. The difference is interesting.
  612.  
  613. Please note: the memory resident and direct screen output features
  614. depend on IBM-PC screen memory and video mode compatibility.  While
  615. vanilla RPN has worked on every PC compatible I've tried it on
  616. including PC jr, and I have not yet had any problems running the memory
  617. resident and direct screen features on the few machines I've been able
  618. to try, there is still room for these features to fail on some
  619. machines.
  620.  
  621. NUMBER BASES
  622.  
  623. As previously mentioned, the calculator will operate in any number base
  624. from 2 to 16.  The number base is set by the "b" key, which will ask
  625. for an input base and a conversion base.
  626.  
  627. The input base determines the range of keys that will be accepted from
  628. the keyboard, the conversion of input data to the computer's internal
  629. format, and the number base of the primary register displays on the
  630. screen.  The conversion base, if different from the input base,
  631. determines the base for a second display of the x and y registers which
  632. is put on the screen to the right of the primary displays.
  633.  
  634. The program comes up with both bases set to 10 for use as a decimal
  635. calculator.  The status line near the top of the screen will say "Base
  636. 10".  To do number base conversions from base 10 to base 16 (for
  637. example), use the "b" key to set the input base to 10 and the
  638. conversion base to 16.  The status line will say "Base 10:16" and there
  639. will be two displays of the x and y registers.  The left display is in
  640. base 10 and the right display is in base 16.
  641.  
  642. FINANCIAL MODE
  643.  
  644. The calculator's financial mode implements the standard formulae for
  645. computing one of five related values from the known values of the other
  646. four.  The financial mode screen displays the registers reserved for
  647. these values on the lower half of your screen.  They are:
  648.  
  649.     N: The number of periods. 
  650.     I: The annual interest rate in percent (APR).
  651.     S: The starting or present value.
  652.     T: The terminal or future value.
  653.     P: The periodic payment.
  654.  
  655. Using this mode you can figure out mortgage payments, accumulation of
  656. savings, annuities, and several other kinds of financial situations
  657. that fit the pattern.
  658.  
  659. When you enter financial mode the first time the default period will be
  660. months.  You can change the period to days, weeks, months, quarters, or
  661. years with the \p function.  This allows the program to internally
  662. compute the periodic interest rate from the annual interest rate you
  663. enter into the interest register.
  664.  
  665. Let's start off with the good ol' home mortgage payment calculation as
  666. an example.  First you would get into financial mode by keying in "\a"
  667. and making sure the period is set to "months".  You then enter the
  668. known values into the financial registers by keying the value in so it
  669. appears in the x register on the stack and then poke the appropriate
  670. Enter/Compute operation key from the financial help menu at the bottom
  671. of the screen.  The program watches numeric input and decides to do
  672. Enter if you have just keyed in a number and Compute if no number has
  673. been keyed in since the last Enter.
  674.  
  675.     For a 30 year mortgage, key in "360N".
  676.     For a 13.5% annual interest rate, Key in "13.5I".
  677.     For a $90,000 loan amount, key in "90000S".
  678.     For a fully amortized loan, the future value is 0 so
  679.         key in "0T" if the register does not already
  680.         contain 0.
  681.     To compute the monthly payment, key in "P". The calculator
  682.         will compute and display "-1030.87".
  683.  
  684. Note the value of the payment is negative.  Since this calculation was
  685. done from the point of view of the borrower the loan amount is
  686. positive, representing an amount being paid in at the beginning of the
  687. loan.  The negative payment signifies an amount being periodically paid
  688. out from the point of view of the calculation.  If we looked at the
  689. loan from the lender's point of view the signs would be reversed.  Now
  690. that these values have been entered, try entering different interest
  691. rates and recomputing the payment to see the effect.
  692.  
  693. Remember that any one of these variables can be computed from the other
  694. four.  In the above example, suppose you could afford a $900 monthly
  695. payment and use the program to determine what interest rate you would
  696. have to shop for.
  697.  
  698.     For a $900 payment, key in "900~P". The "~" changes
  699.         the sign of the payment to negative, which is
  700.         necessary for our point of view.
  701.     To compute the interest rate, key in "I". The program will
  702.         go away and work for a while on this one but it will 
  703.         come back in a few seconds with the answer, "11.63".
  704.  
  705. For the next example, we'll do the IRA (Individual Retirement Account)
  706. routine to see how savings accumulation works.  Since we are going to
  707. enter a complete new set of numbers, first use "y" to clear the
  708. financial registers.  Now, lets assume you want to put $2000 per year
  709. into your IRA for 30 years and you will do it by depositing $500 each
  710. quarter (3 months).  Key in "\p" to change the period and answer the
  711. "What period?" question with a "q" for "quarter".  Now enter the known
  712. values:
  713.  
  714.     For 120 quarters (30 years), key in "120N".
  715.     For 12% interest rate (APR), key in "12I".
  716.     For $500 payment to the account, key in "500~P". Remember
  717.         our point of view. This is an outgoing payment.
  718.     The present value is 0, so the S register is OK.
  719.     To compute the future value, key in "T". WOW!! Don't you
  720.         wish you had started this 30 years ago? You might
  721.         have had $561,849.79 by now.
  722.  
  723. There are many financial situations that fit this pattern.  Remember
  724. that the number of periods and interest rate are always positive. 
  725. Negative values have no sensible interpretation.  Present value, future
  726. value, and periodic payment are either positive or negative depending
  727. on whether cash is flowing to you or away from you.  The correct sign
  728. for the known values must be entered for the calculation to work
  729. correctly.  The sign of a computed answer tells the direction of cash
  730. flow.
  731.  
  732. MACROS
  733.  
  734. The program's macro capability allows you to define sequences of
  735. keypokes which will be remembered by the program and executed on
  736. demand.  There are 11 macro storage strings defined.  Ten of these are
  737. used to hold macros assigned to the 10 function keys.  The 11th is a
  738. scratch area which is used for initial definitions, macro execution,
  739. and macro editing.
  740.  
  741. There are two ways within the program to define a macro string.  The
  742. first is the "\m" operation which starts collecting and remembering
  743. keypokes as you actually execute them on the calculator.  This
  744. collection process will continue until you fill up the macro storage
  745. string (76 characters) or until you enter the "\m" keys a second time
  746. to signal the end of the macro entry.  The status line near the top of
  747. the screen will tell you when macro definition is in progress.  In this
  748. macro entry mode there can be no backing up to correct mistakes.
  749.  
  750. The second way to define a macro string is with the macro editor, which
  751. is capable of examining and modifying the scratch string and assigning
  752. its contents to one of the 10 function keys.  The macro editor is
  753. entered by the "M" key and exited either by a second use of the "M" key
  754. or by use of one of the function keys.  Use of "M" to exit the editor
  755. leaves the edited macro in the scratch string where it can be executed
  756. with "m".  Use of a function key to exit the editor causes the edited
  757. macro to be copied from the scratch storage to the string assigned to
  758. the function key.
  759.  
  760. When entered, the macro editor will display the macro currently
  761. resident in the scratch area.  This may be the macro just entered with
  762. "\m", or the last macro executed by a function key, or it may be empty. 
  763. You may edit the macro with the following edit keys:
  764.  
  765.     cursor left ---- non destructive left cursor motion
  766.     cursor right --- non destructive right cursor motion
  767.     home ----------- moves cursor to beginning of line
  768.     end ------------ moves cursor to end of line
  769.     delete --------- deletes character the cursor is currently on
  770.     backspace ------ deletes character before the cursor position
  771.  
  772. Printing characters in the range from "!" to "~" are inserted into the
  773. line before the current cursor position.  Characters outside this
  774. range, except for the edit keys, are ignored.  Aside from excluding
  775. non-printing characters and limiting macro size the editor makes no
  776. tests on the validity of the characters you enter so you are
  777. responsible for the logic and executability of the changes you make.
  778.  
  779. To edit a macro assigned to a function key, it is necessary to move it
  780. to the scratch string.  This happens when the macro is executed by
  781. poking its function key.  To move it without execution, poke the "\"
  782. key followed by the function key. Then use "M" to enter the editor.
  783.  
  784. Brief comments may be inserted in macro strings by enclosing them in
  785. square brackets.  This may be useful if you are going to save macros in
  786. a disk file but the comment uses up macro keypokes.  Here are some
  787. sample macros (in RPN) to do the Fahrenheit to Centigrade and
  788. Centigrade to Fahrenheit conversions:
  789.  
  790.     [C to F]=9=5/*32+
  791.     [F to C]=32-5=9/*
  792.  
  793. Notice in the RPN macros above the uses of the ENTER key are stored as
  794. equals signs.  Inside the calculator all the keys (space, newline,
  795. return, and =) which are interpreted as ENTER are converted to the
  796. equals sign, partly because it is the only printing character of the
  797. group and partly because it makes sense in algebraic mode where the
  798. same set of keys is used as EQUALS.
  799.  
  800. The same calculations as they could be entered as a macro in algebraic
  801. mode would look like this:
  802.  
  803.     [C to F]*9/5+32=
  804.     [F to C]-32*5/9=
  805.  
  806. Normally, execution of a macro proceeds exactly as if the characters
  807. from the macro string were being entered from the keyboard.  The values
  808. contained in the stack on exit from the macro will be those left from
  809. the calculations in the macro and will likely be different from the
  810. values on entry.  In many cases this makes no difference and in fact
  811. may be desirable.  Perhaps just as often, however, it is desirable to
  812. write a macro to do some sort of a conversion or other function and
  813. return a value to the x register much as the built-in functions such as
  814. log and square root do. In such a function, you would prefer not to have
  815. the stack altered by the macro (except for the x register, of course).
  816.  
  817. The macro function flag (#) character, inserted at the beginning of a
  818. macro, indicates that the macro is to be treated as a function returning
  819. a result to the x register. This causes the y, z, and t registers to
  820. be saved while the macro is executing and restored when the macro ends.
  821. Whatever the macro leaves in the x register is assumed to be the result
  822. and is left there. Also the flags that control processing of input are
  823. set to indicate that a new number input is expected (in other words,
  824. any number entry in progress when the macro terminates is ended as if
  825. the ENTER key had been poked). In algebraic mode, a pending operation
  826. is saved and restored at the end of the macro execution, allowing the
  827. result of a macro function to be included in a chain calculation.
  828.  
  829. For example, if you put the radius of a circle in the x register, a
  830. macro to find the area of the circle wuold be "\q*p=" in algebraic mode.
  831. If you enter this and execute it, you'll see that it changes the y register.
  832. A little further experimentation will show that the result can't be used
  833. in a chain calculation except at the beginning. Now change the macro so
  834. it is "#\q*p=" and try again. Now executing the macro saves y when the
  835. "#" is encountered and restores it when the macro finishes. It also saves
  836. any pending operation and propogates it across the macro so you can do
  837.  
  838.     1+2.5m+4m=
  839.  
  840. and get the right answer. It is algebraic mode where this is really
  841. necessary. In RPN mode you can get along without this because the problem
  842. of remembering pending operations does not exist, but it still can be
  843. handy to preserve the contents of the y, z, and t registers through
  844. macro execution.
  845.  
  846. By the way, I realize that the next extension of this is to allow a macro
  847. to use another macro and that may happen in a later revision but is not
  848. handled now. 
  849.  
  850. SAVING MACROS IN A DISK FILE
  851.  
  852. The macros assigned to function keys may be saved in a disk file and
  853. restored whenever the program is executed.  Up to 10 sets of macros may
  854. be saved in RPN mode and 10 more in algebraic mode (RPN and algebraic
  855. macros are not interchangable, hence separation of macro files).  The
  856. file names are of the format RPN.R0 to RPN.R9 for RPN macros and RPN.A0
  857. to RPN.A9 for algebraic macros.  The "\M" function will ask you for a
  858. digit from 0-9 to specify the file number and then will write the
  859. macros in the appropriate file, creating the file if necessary or
  860. overwriting an existing file.
  861.  
  862. When the program is executed it looks by default for macro file 0.  You
  863. can specify which file you want it to load by a 0 to 9 digit in the
  864. first parameter.  For example, the following will attempt to find and
  865. load macros from RPN.R4.
  866.  
  867.     RPN R4
  868.  
  869. The macro file is clear text and as such can be changed with a text
  870. editor.  Be careful not to disturb the file structure if you try this. 
  871. The format of the macro save file is:
  872.  
  873.     The color attributes: (comment line)
  874.     - -
  875.     (14 lines containing color attributes)
  876.     - -
  877.     The function key macros for F1-F10: (comment line)
  878.     - -
  879.     (10 lines containing macro definitions)
  880.     - -
  881.     End of file. (comment line)
  882.  
  883. CHANGING SCREEN COLORS
  884.  
  885. If you feel like experimenting with screen colors, you can do it
  886. without recompiling the program.  The screen colors used are written
  887. out to the macro file and can be changed by a text editor.  When a
  888. macro file is loaded during program initialization, the colors stored
  889. in the macro file will override the defaults in the program.  The
  890. defaults, in the order they are written are:
  891.  
  892.     15 --- Title color (normal & memory mode)
  893.     13 --- Status color (normal & memory mode)
  894.     14 --- Register color (normal & memory mode)
  895.     12 --- Message color (normal & memory mode)
  896.     3 ---- Help color (normal & memory mode)
  897.     0 ---- Background color (normal & memory mode)
  898.     0 ---- Border color (normal & memory mode)
  899.     15 --- Title color (financial & summation mode)
  900.     13 --- Status color (financial & summation mode)
  901.     14 --- Register color (financial & summation mode)
  902.     10 --- Message color (financial & summation mode)
  903.     3 ---- Help color (financial & summation mode)
  904.     0 ---- Background color (financial & summation mode)
  905.     0 ---- Border color (financial & summation mode)
  906.  
  907. Following the color data are the macros, and the final line says "End
  908. of file".
  909.  
  910. ERROR MESSAGES
  911.  
  912. The calculator will eventually be told to do something that it can't
  913. do.  If I haven't thought of it in advance you may get an error from
  914. the floating point routines and possibly get kicked out of the program
  915. or get incorrect results.
  916.  
  917. If I have thought of it in advance, you will probably get beeped at and
  918. get an error message on the message line of the screen.  The error
  919. messages defined currently are:
  920.  
  921. "Divide by zero." 
  922. The denominator of an "o", "/" or "%" function is 0.
  923.  
  924. "Illegal argument."
  925. From "%" when the argument is too large or not an integer.  From "!", 
  926. "&", "|", and "$" if the argument is not an integer.
  927.  
  928. "Overflow."
  929. From factorial if the argument is greater than 170.
  930.  
  931. "Valid in decimal only."
  932. From enter exponent if the number base is not 10.
  933.  
  934. "Illegal during macro definition."
  935. Macros are not recursive so it's illegal to hit "m" or a macro function
  936. key during a macro definition phase.  It's also illegal to enter the
  937. macro editor during macro definition.
  938.  
  939. "Macros not recursive."
  940. If this happens, an "m" was encountered during a macro execution.  It
  941. was probably entered into the macro during an edit session.
  942.  
  943. "Macro not defined."
  944. This happens when a macro execution or copy is requested and the macro
  945. definition is found to be empty.
  946.  
  947. "Did not converge."
  948. This means that the interest rate calculation in financial mode did not
  949. converge to an answer in a reasonable number of iterations.  Make sure
  950. you are asking it to do something reasonable.
  951.  
  952. "Does not compute."
  953. This error is the result of one of several tests for gotchas during any
  954. of the financial computations.  What it generally means is that the
  955. data in the financial registers is inconsistent and an answer can't be
  956. computed.  An example of this is the attempt to compute a number of
  957. payments necessary to pay off a loan when the periodic payment
  958. specified is less than or equal to the periodic interest on the loan.
  959.  
  960. "Floating point domain error."
  961. This is from an error code set by a floating point routine when it
  962. gets input which is invalid for the function being computed.
  963. Example: Arcsin or arccos of a value greater than 1.
  964.  
  965. "Floating point range error."
  966. This is from another error code set by a floating point routine when
  967. a calculation results in overflowing the range of numbers the
  968. computer can represent internally. Example: exp(695)
  969.  
  970.  
  971. -------------------------
  972. In this document I have made reference to the following:
  973.     IBM PC, PC jr, and PC-DOS are trademarks of IBM Corp.
  974.     MS is a trademark of Microsoft.
  975.     Sidekick is a trademark of Borland International
  976.  
  977.